<!DOCTYPE html>
<html style="background-color: #f2f2f2;" lang="en">
<%include("/common/header.html",{title:''}){}%>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">

        <div class="layui-row layui-col-space15">
            <div class="layui-col-md6">
                <div class="layui-card">
                    <div class="layui-card-header">快捷方式</div>
                    <div class="layui-card-body">

                        <div class="layui-carousel layadmin-carousel layadmin-shortcut">
                            <div carousel-item>
                                <ul class="layui-row layui-col-space10">
                                    <li class="layui-col-xs3">
                                        <a lay-href="base/link/@/salesperson/clientList.jhtml">
                                            <i class="layui-icon iconfont layui-extend-tenantuser"></i>
                                            <cite>用户列表</cite>
                                        </a>
                                    </li>
                                    <li class="layui-col-xs3">
                                        <a lay-href="base/link/@/salesperson/order.jhtml">
                                            <i class="layui-icon iconfont layui-extend-gouwudingdan1"></i>
                                            <cite>购物订单</cite>
                                        </a>
                                    </li>
                                    <li class="layui-col-xs3">
                                        <a lay-href="base/link/@/salesperson/addService.jhtml">
                                            <i class="layui-icon iconfont layui-extend-zengzhifuwu1"></i>
                                            <cite>增值服务订单</cite>
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </div>

                    </div>
                </div>
            </div>

            <div class="layui-col-md6">
                <div class="layui-card">
                    <div class="layui-card-header">数据统计</div>
                    <div class="layui-card-body">

                        <div class="layui-carousel layadmin-carousel layadmin-backlog">
                            <div carousel-item>
                                <ul class="layui-row layui-col-space10">
                                    <li class="layui-col-xs6">
                                        <a class="layadmin-backlog-body">
                                            <h3>用户数</h3>
                                            <p><cite style="color: #FF5722;" id="wwcxc"></cite></p>
                                        </a>
                                    </li>
                                    <li class="layui-col-xs6">
                                        <a class="layadmin-backlog-body">
                                            <h3>销售总套数</h3>
                                            <p><cite>${session.om_user.saleNumber}</cite></p>
                                        </a>
                                    </li>
                                    <li class="layui-col-xs6">
                                        <a class="layadmin-backlog-body">
                                            <h3>总销售额</h3>
                                            <p><cite>${session.om_user.saleMoney}</cite></p>
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<%include("/common/foot.html"){}%>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
<script>
    var $;
    layui.use(['index', 'console','table'], function () {
        /*  var $A = layui.AjaxCommon;
          var al = layui.AliangLayui;
          $A.ajax('http://route.showapi.com/32-9', 'post', 'json', {
            'showapi_appid': 28043,
            'showapi_sign': 'fd5ce066f69441bfa078c0ad16129b15',
            'q': 'hello'
          }, function (res) {
            //alert(JSON.stringify(res));
          });*/
        $ = layui.jquery;
        var table = layui.table;
        //展示已知数据
        //已激活用户数
    });
    (function () {
        /*----------------施工角色-健康异常统计-Start--------------------*/
        let admin_healthy_static = new Promise(function (resolve, reject) {
            $.ajax({
                url: "system/healthy_statistics/admin_healthy_static.json",
                type: "POST",
                data: {},
                dataType: "json",
                success: function (ret) {
                    if (ret) {
                        resolve(ret);
                    } else {
                        alert("网络异常，请稍后再试吧" + JSON.stringify(err))
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                }
            });
        });
        admin_healthy_static.then(data => {
            admin_healthy_static_fn(data.worklist, data.daylist);
        });
        /*----------------施工角色-健康异常统计-END---------------------*/

        /*----------------施工角色-缺勤统计-Start--------------------*/
        let admin_att_static = new Promise(function (resolve, reject) {
            $.ajax({
                url: "system/att_checkwork/admin_att_static.json",
                type: "POST",
                data: {},
                dataType: "json",
                success: function (ret) {
                    if (ret) {
                        resolve(ret);
                    } else {
                        alert("网络异常，请稍后再试吧" + JSON.stringify(err))
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                }
            });
        });
        admin_att_static.then(obj => {
            admin_att_static_fn(obj.worklist, obj.daylist);

        });
        /*----------------施工角色-缺勤统计-END--------------------*/

        /*----------------施工角色-精细养护-Start--------------------*/
        let mainten = new Promise(function (resolve, reject) {
            $.ajax({
                url: "maintenstatistics/sgtop.json",
                type: "POST",
                data: {},
                dataType: "json",
                success: function (ret) {
                    if (ret) {
                        resolve(ret);
                    } else {
                        alert("网络异常，请稍后再试吧" + JSON.stringify(err))
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                }
            });
        });
        mainten.then(obj => {
            var data = JSON.parse(obj.data);
            $("#lv").text(data.lv);
            $("#ws").text(data.ws);
            $("#ss").text(data.ss);
            $("#zb").text(data.zb);
            mainten_fn(data.lv,data.ws,data.ss,data.zb);

        });



        /*----------------用户数--------------------*/
        let wwcxc = new Promise(function (resolve, reject) {
            var findSaleManUserNumber_url="saleMan/data/findUserNumber.jhtml"
            $.ajax({
                url: findSaleManUserNumber_url,
                type: "POST",
                data: {},
                dataType: "json",
                success: function (ret) {
                    if (ret) {
                        resolve(ret);
                    } else {
                        alert("网络异常，请稍后再试吧" + JSON.stringify(err))
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                }
            });
        });
        wwcxc.then(obj => {
            $("#wwcxc").text(obj.data.length);

        });
        /*----------------施工角色-巡查豆腐-END--------------------*/
        /*----------------施工角色-巡查图-Start--------------------*/
        let sctu = new Promise(function (resolve, reject) {
            $.ajax({
                url: "system/count/patrolCompleteByMonth.jhtml",
                type: "POST",
                data: {},
                dataType: "json",
                success: function (ret) {
                    if (ret) {
                        resolve(ret);
                    } else {
                        alert("网络异常，请稍后再试吧" + JSON.stringify(err))
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                }
            });
        });
        sctu.then(obj => {
            //console.log(obj,1111111111111111111111111);
            xcctu(obj.data.month,obj.data.com,obj.data.unCom);

        });
        /*----------------施工角色-巡查豆腐-END--------------------*/


        function mainten_fn(lv,ws,ss,zb) {
            //饼图（精细养护）
            var dom = document.getElementById("container");
            var myChart = echarts.init(dom);
            var app = {};
            option = null;
            option = {
                color: ['#60acfc', '#5bc49f', '#ff7c7c', '#9287e7'],
                title: {
                    text: '精细养护分类占比',
                    subtext: '四大分类',
                    left: 'center'
                },
                tooltip: {
                    trigger: 'item',
                    formatter: '{a} <br/>{b} : {c} ({d}%)'
                },
                legend: {
                    orient: 'vertical',
                    left: 'left',
                    data: ['绿地养护', '卫生清理', '设施维护', '植保管理']
                },
                series: [
                    {
                        name: '精细养护分类',
                        type: 'pie',
                        radius: '55%',
                        center: ['50%', '60%'],
                        data: [
                            {value: lv, name: '绿地养护'},
                            {value: ws, name: '卫生清理'},
                            {value: ss, name: '设施维护'},
                            {value: zb, name: '植保管理'},

                        ],
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            };
            if (option && typeof option === "object") {
                myChart.setOption(option, true);
            }
        }

        //////////////////////////////////////////////////////

        //////////////////////////////////////////////////////

        function  xcctu(date,com,uncom) {
            //柱图（巡查逐月）
            var dom = document.getElementById("container2");
            var myChart = echarts.init(dom);
            var app = {};
            option = null;
            option = {
                title: {
                    text: '巡查次数逐月统计',
                    subtext: '完成/未完成'
                },
                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    data: ['完成', '未完成']
                },
                calculable: true,
                xAxis: [
                    {
                        type: 'category',
                        data:date
                    }
                ],
                yAxis: [
                    {
                        type: 'value'
                    }
                ],
                series: [
                    {
                        name: '完成',
                        type: 'bar',
                        color: '#60ACFC',
                        data:com,
                        markPoint: {
                            data: [
                                {type: 'max', name: '最大值'},
                                {type: 'min', name: '最小值'}
                            ]
                        },
                        markLine: {
                            data: [
                                {type: 'average', name: '平均值'}
                            ]
                        }
                    },
                    {
                        name: '未完成',
                        type: 'bar',
                        color: '#AFE39B',
                        data: uncom,
                        markPoint: {
                            data: [
                                {name: '年最高', value: 182.2, xAxis: 7, yAxis: 183},
                                {name: '年最低', value: 2.3, xAxis: 11, yAxis: 3}
                            ]
                        },
                        markLine: {
                            data: [
                                {type: 'average', name: '平均值'}
                            ]
                        }
                    }
                ],
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '0%',
                    top: '25%',
                    containLabel: true
                }
            };
            if (option && typeof option === "object") {

                myChart.setOption(option, true);
            }
        }



        function admin_healthy_static_fn(worklist, daylist) {
            //折线图（健康异常）
            var dom = document.getElementById("container3");
            var myChart = echarts.init(dom);
            var app = {};
            option = null;
            option = {
                color: '#66AFFC',
                tooltip: {
                    trigger: 'axis'
                },
                xAxis: {
                    type: 'category',
                    data: daylist
                },
                yAxis: {
                    type: 'value'
                },
                series: [{
                    name: '异常',
                    data: worklist,
                    type: 'line',
                    smooth: true
                }]
            };
            if (option && typeof option === "object") {
                myChart.setOption(option, true);
            }
        }

        //////////////////////////////////////////////////////
        function admin_att_static_fn(worklist, daylist) {
//折线图（缺勤人数）
            var dom = document.getElementById("container4");
            var myChart = echarts.init(dom);
            var app = {};
            option = null;
            option = {
                color: '#5FC5A1',
                tooltip: {
                    trigger: 'axis'
                },
                xAxis: {
                    type: 'category',
                    data: daylist
                },
                yAxis: {
                    type: 'value'
                },
                series: [{
                    name: '缺勤',
                    data: worklist,
                    type: 'line',
                    smooth: true
                }]
            };
            if (option && typeof option === "object") {
                myChart.setOption(option, true);
            }
        }
    }())

</script>
</body>
</html>